<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>任务管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/task/taskList.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
</head>
<body>
    <div class="tast-box" id="TaskBox">
    
    </div>
<body>
<script type="text/html" id="Tpl">
    <%if(list){
        for(var i=0;i<list.length;i++){
            var item=list[i];
            item.baseUrl='{$Think.config.SERVER_HOST}';
        %>
        <dl>
            <dt>
                <%if(item.reward.KEY=="REDENVE") {%>
                    <img src="/wx_assets/task/img/hongbao.jpg">
                <%}else if(item.reward.KEY=="ACCOUNT"){%>
                    <img src="/wx_assets/task/img/ico-account.png">
                <%}%>
            </dt>
            <dd class="mid">
                <div class="target">
                    <%=item.name%>
                </div>
                <div class="progress-box">
                    <div class="label">进度：</div>
                    <div class="progress">
                        <%if(item.ustatus==1) {%>
                            <div class="inner" style="width:<%=item.per%>%"></div>
                        <%} else if(item.ustatus==2 || item.ustatus==3) {%>
                            <div class="inner" style="width:100%"></div>
                        <%} else {%>
                            <div class="inner"></div>
                        <%}%>
                    </div>
                    <div class="per">
                    <%if(item.ustatus==2 || item.ustatus==3) {%>
                        完成
                    <%} else if(item.ustatus==1) {%>
                        <%=item.rate%>
                    <%}%>
                    </div>
                </div>
            </dd>
            <dd class="right">
                <a onclick="taskList.toDetail(<%=item.taskid%>)" class="btn"></a>
            </dd>
        </dl>
        <%}%>
    <%} else {%>
        <div class="norecord">当前没有可领取的任务</div>
    <%}%>
</script>
<script type="text/javascript">
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var taskList={
        pageSize:10,
        page:0,
        init:function(){
            var me=this;
            this._initEvent();
            $.util.pageLoading.show();
            me._loadList(me.page,function(){
                $.util.pageLoading.hide();
            });
        },
        toDetail:function(tId){
            var params={
                "tId":tId,
                "qId":"{$qId}"
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId={$customerId}&module=task&method=index&params='+params;
        },
        _initEvent:function(){
            var me=this;
            $.util.initDataLoading({
                me:taskList,
                lastChildren:function(){
                    return $("#TaskBox dl:last");
                },
                page:function(){
                    return taskList.page; 
                },
                pageCount:function(){
                    return taskList.pageCount;
                }
            });
        },
        _renderList:function(data,page,callback){
           var me=this;
           if(data){
                var html=template("Tpl", data),
                    container=$("#TaskBox");
                container.append(html);
                me.page=page;
                me.pageCount=data.pageCount;
                callback && callback();
           }   
        },
        _loadList:function(page,callback){
            var me=this;
            $.req.get("call.json?module=task&customerId={$customerId}&method=gettaskListData",{
                userName:"{$userName}",
                params:{
                    "qId":"{$qId}",
                    "start":page,
                    "limit":me.pageSize
                }
            },function(data){
                if(data){
                    me._renderList(data,page,callback);
                }
            });
        }
    }
    taskList.init();
     wx_share.init({
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": {$pkg.timestamp},
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        hide:1
    });
</script>
</body>
</html>